//
//  ViewController.h
//  tentecthORC
//
//  Created by 湖南机友科技有限公司 on 2018/3/22.
//  Copyright © 2018年 湖南机友科技有限公司. All rights reserved.
//


#define host_api       @"http://addnum.jiyw.com/"

#define very_api       @"api/Client/SendSms"
#define register_api   @"api/Client/Register"
#define login_api      @"api/Client/Login"


#define user_token   @"user_token"
#define user_messageId   @"user_messageId"

/*列出分配到自己的微信号，如果是主号，就列出所有。*/
#define ListPhoneDetail_api     @"api/Client/ListPhoneDetail"


/* 更新微信状态 。*/
#define UpdateMobileInfol_api     @"api/Client/UpdateMobileInfo"


/*更新 手机状态。*/
#define UpdateMobileStatus_api     @"api/Client/UpdateMobileStatus"


/*上传通讯录 。*/
#define AddMobilePhone_api     @"api/Client/AddMobilePhone"

/* 删除 。*/
#define DeletBatch_api     @"api/Client/BatchDelete"
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController


@end



/**

 //================================ 排序与 MD5=====================================================

 NSArray *keyArray = [params allKeys];
 NSArray *sortArray = [keyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
 return [obj1 compare:obj2 options:NSNumericSearch];
 }];

 NSLog(@"sortArray:%@",sortArray);

 NSMutableArray *valueArray = [NSMutableArray array];
 for (NSString *sortString in sortArray) {
 [valueArray addObject:[params objectForKey:sortString]];
 }
 NSMutableArray *signArray = [NSMutableArray array];
 for (int i = 0; i < sortArray.count; i++) {
 NSString *keyValueStr = [NSString stringWithFormat:@"%@:%@",sortArray[i],valueArray[i]];
 [signArray addObject:keyValueStr];
 }
 NSString *sign = [signArray componentsJoinedByString:@"&"];
 NSString *strUrl = [sign stringByReplacingOccurrencesOfString:@":" withString:@"="];
 NSString *appendStr=[strUrl stringByAppendingString:@"&app_key=zvVIWBt07Tl3uQlM"];

 NSString *md5result = [[self md5:appendStr] uppercaseString];
 //    NSLog(@"sign   %@   ------------ /n\n %@",md5result,appendStr);

 //===============================================================================================

 
 NSDictionary *dict = @{
 @"app_id":@"1106795032",
 // @"image":urlEncodingString,
 @"time_stamp":timeStr,
 @"nonce_str":randomStr,
 //@"sign":@"73A0720EAF720F138B78F93D65AE673A"
 };

 NSArray *allKeyArray = [dict allKeys];
 /// 降序
 //    NSArray *afterSortKeyArray = [allKeyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
 //        NSComparisonResult resuest = [obj2 compare:obj1];
 //        return resuest;
 //    }];
 /// 生序
 NSArray *afterSortKeyArray = [allKeyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
 return [obj1 compare:obj2 options:NSNumericSearch];
 }];
 NSLog(@"afterSortKeyArray:%@",afterSortKeyArray);

 //通过排列的key值获取value
 NSMutableArray *valueArray = [NSMutableArray array];
 for (NSString *sortsing in afterSortKeyArray) {
 NSString *valueString = [dict objectForKey:sortsing];
 [valueArray addObject:valueString];
 }
 NSLog(@"valueArray:%@",valueArray);


 NSMutableArray *signArray = [NSMutableArray array];
 for (int i = 0 ; i < afterSortKeyArray.count; i++) {
 NSString *keyValue = [NSString stringWithFormat:@"%@=%@",afterSortKeyArray[i],valueArray[i]];
 [signArray addObject:keyValue];
 }

 //signString用于签名的原始参数集合
 NSString *signString = [signArray componentsJoinedByString:@"&"];

 NSString *appendStr=[signString stringByAppendingString:@"&app_key=zvVIWBt07Tl3uQlM"];

 NSString *md5result = [[self md5:appendStr] uppercaseString];

 NSLog(@"signString====:%@",md5result);
 */

